package com.cherrypt.api.model.bo;

import com.cherrypt.api.model.util.BeanUtils;
import com.cherrypt.api.model.dataobject.UserInfo;
import com.cherrypt.api.model.dataobject.UserLogin;
import com.cherrypt.api.model.dto.UserDto;
import org.apache.commons.lang3.StringUtils;

public class UserBo {
    public static UserDto getUserDto(UserLogin userLogin, UserInfo userInfo, String token) {
        UserDto userDTO = new UserDto();
        if (userLogin != null) {
            BeanUtils.copyFieldToBean(userLogin, userDTO);
        }
        if (userInfo != null) {
            BeanUtils.copyFieldToBean(userInfo, userDTO);
        }
        if (StringUtils.isNotBlank(token)) {
            userDTO.setToken(token);
        }
        return userDTO;
    }
}
